package com.navinfo.opentsp.platform.computing.dto;


import com.navinfo.opentsp.platform.computing.util.EntityConvert;
import com.navinfo.opentsp.platform.location.protocol.common.LCPredictiveMaintenance;

public class MaintenanceEventF0Dto {

    private int openStatus;   //燃油防盗开启状态
    private int systemStatus; //燃油防盗系统状态


    public int getOpenStatus() {
        return openStatus;
    }

    public void setOpenStatus(int openStatus) {
        this.openStatus = openStatus;
    }

    public int getSystemStatus() {
        return systemStatus;
    }

    public void setSystemStatus(int systemStatus) {
        this.systemStatus = systemStatus;
    }

    public static MaintenanceEventF0Dto parseProto(LCPredictiveMaintenance.MaintenanceEventF0 maintenanceEventF0){
        MaintenanceEventF0Dto maintenanceEventF0Dto = new MaintenanceEventF0Dto();
        maintenanceEventF0Dto.setOpenStatus(maintenanceEventF0.getOpenStatus());
        maintenanceEventF0Dto.setSystemStatus(maintenanceEventF0.getSystemStatus());
        return maintenanceEventF0Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEventF0
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEventF0 maintenanceEventF0){
        return EntityConvert.convert(
                maintenanceEventF0.getOpenStatus(),
                maintenanceEventF0.getSystemStatus()
        );
    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEventF0 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEventF0.Builder builder = null;

        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=2){
                builder =LCPredictiveMaintenance.MaintenanceEventF0.newBuilder();
                builder.setOpenStatus(Integer.valueOf(revert[0]));
                builder.setSystemStatus(Integer.valueOf(revert[1]));
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }

}
